<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .pass {color: green;}
        .fail{color: red;}
    </style>
</head>
<body>
<button id="test">Click Me!</button>
<ul id="results"></ul>
<script>
    function assert(value, desc) {
        const li = document.createElement("li");
        li.className = value ? "pass": "fail";
        li.appendChild(document.createTextNode(desc));
        document.getElementById("results").appendChild(li);
    }
    function report(text) {
        assert(true, text);
    }
    function Button() {
        this.clicked = false;
        this.click = function () {
            this.clicked= true;
            assert(this.clicked, "The button has been clicked");
        };
    }
    var button = new Button();
    console.log(button)
    var elem = document.getElementById("test");
    elem.addEventListener("click", button.click.bind(button));
</script>
</body>
</html>